package com.groupbuying.payconsumer.service.impl;


import com.groupbuying.payconsumer.constants.CommonConstants;
import com.groupbuying.payconsumer.constants.PayOrderRelSearchConstants;
import com.groupbuying.payconsumer.dao.PayOrderRelDao;
import com.groupbuying.payconsumer.domain.PayOrderRelDO;
import com.groupbuying.payconsumer.service.PayOrderRelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class PayOrderRelServiceImpl implements PayOrderRelService {
    @Autowired
    private PayOrderRelDao payOrderRelDao;

    @Override
    public PayOrderRelDO get(String id) {
        return payOrderRelDao.get(id);
    }

    @Override
    public List<PayOrderRelDO> list(Map<String, Object> map) {
        return payOrderRelDao.list(map);
    }

    @Override
    public int count(Map<String, Object> map) {
        return payOrderRelDao.count(map);
    }

    @Override
    public int save(PayOrderRelDO payOrderRel) {
        return payOrderRelDao.save(payOrderRel);
    }

    @Override
    public int update(PayOrderRelDO payOrderRel) {
        return payOrderRelDao.update(payOrderRel);
    }

    @Override
    public int remove(String id) {
        return payOrderRelDao.remove(id);
    }

    @Override
    public int batchRemove(String[] ids) {
        return payOrderRelDao.batchRemove(ids);
    }

    @Override
    public PayOrderRelDO getRelBuyPayId(String payId) {
        Map serarchMap = new HashMap();
        serarchMap.put(PayOrderRelSearchConstants.SEARCH_ID, payId);
        serarchMap.put(PayOrderRelSearchConstants.SEARCH_ISDELETE, CommonConstants.COMMON_FLAG_UNDEL);
        List<PayOrderRelDO> list = this.list(serarchMap);
        if (list != null && list.size() != 0) {
            return list.get(0);
        }
        return null;
    }

    @Override
    public PayOrderRelDO getByOutTradeNo(String outTradeNo) {
        Map serarchMap = new HashMap();
        serarchMap.put(PayOrderRelSearchConstants.SEARCH_OUTTRADENO, outTradeNo);
        List<PayOrderRelDO> list = this.list(serarchMap);
        if (list != null && list.size() != 0) {
            return list.get(0);
        }
        return null;
    }
}
